package com.farm.resume.service.impl;

import com.farm.core.auth.domain.LoginUser;
import com.farm.core.sql.query.DataQuery;
import com.farm.core.time.TimeTool;
import com.farm.resume.dao.ResumeappraisalDaoInter;
import com.farm.resume.domain.Resumeappraisal;
import com.farm.resume.service.ResumeappraisalServiceInter;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;










@Service
public class ResumeappraisalServiceImpl
  implements ResumeappraisalServiceInter
{
  @Resource
  private ResumeappraisalDaoInter resumeappraisalDaoImpl;
  
  @Transactional
  public Resumeappraisal insertResumeappraisalEntity(Resumeappraisal entity, LoginUser user)
  {
    entity.setCuser(user.getId());
    entity.setCtime(TimeTool.getTimeDate14());
    entity.setCusername(user.getName());
    entity.setEuser(user.getId());
    entity.setEusername(user.getName());
    entity.setEtime(TimeTool.getTimeDate14());
    entity.setPstate("1");
    return this.resumeappraisalDaoImpl.insertEntity(entity);
  }
  
  @Transactional
  public Resumeappraisal editResumeappraisalEntity(Resumeappraisal entity, LoginUser user)
  {
    Resumeappraisal entity2 = this.resumeappraisalDaoImpl.getEntity(entity.getId());
    entity2.setEuser(user.getId());
    entity2.setEusername(user.getName());
    entity2.setEtime(TimeTool.getTimeDate14());
    entity2.setCareergoals(entity.getCareergoals());
    entity2.setAppraisal(entity.getAppraisal());
    entity2.setUserid(entity.getUserid());
    this.resumeappraisalDaoImpl.editEntity(entity2);
    return entity2;
  }
  

  @Transactional
  public void deleteResumeappraisalEntity(String id, LoginUser user)
  {
    this.resumeappraisalDaoImpl.deleteEntity(this.resumeappraisalDaoImpl.getEntity(id));
  }
  

  @Transactional
  public Resumeappraisal getResumeappraisalEntity(String id)
  {
    if (id == null) {
      return null;
    }
    return this.resumeappraisalDaoImpl.getEntity(id);
  }
  

  @Transactional
  public DataQuery createResumeappraisalSimpleQuery(DataQuery query)
  {
    DataQuery dbQuery = DataQuery.init(query, "FARM_RESUME_APPRAISAL", 
      "ID,CAREERGOALS,APPRAISAL,USERID,PCONTENT,PSTATE,EUSERNAME,EUSER,CUSER,CUSERNAME,ETIME,CTIME");
    return dbQuery;
  }
  
  public ResumeappraisalDaoInter getResumeappraisalDaoImpl()
  {
    return this.resumeappraisalDaoImpl;
  }
  
  public void setResumeappraisalDaoImpl(ResumeappraisalDaoInter dao) {
    this.resumeappraisalDaoImpl = dao;
  }
  
  @Transactional
  public Resumeappraisal getResumeappraisalEntityByUser(String userid)
  {
    return this.resumeappraisalDaoImpl.getResumeappraisalEntityByUser(userid);
  }
}
